package com.smmisia.article.controller;

import com.smmisia.article.request.ScenicSpotCreateRequest;
import com.smmisia.article.request.ScenicSpotUpdateRequest;
import com.smmisia.article.response.ScenicSpotResponse;
import com.smmisia.article.service.ScenicSpotService;
import com.smmisia.common.Result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/scenicSpot")
@Tag(name = "景区管理",description = "景区管理")
public class ScenicSpotController {

    @Autowired
    private ScenicSpotService scenicSpotService;

    /**
     * 创建景区
     * @param request
     * @return
     */
    @PostMapping("/create")
    @Operation(summary = "创建景区")
    public Result<Boolean> createScenicSpot(@Valid @RequestBody ScenicSpotCreateRequest request){
        return scenicSpotService.create(request);
    }

    /**
     * 更新景区
     * @param request
     * @return
     */
    @PostMapping("/update")
    @Operation(summary = "更新景区")
    public Result<Boolean> updateScenicSpot(@Valid @RequestBody ScenicSpotUpdateRequest request){
        return scenicSpotService.updateScenicSpot(request);
    }

    /**
     * 删除景区
     * @param id
     * @return
     */
    @GetMapping("/delete")
    @Operation(summary = "删除景区")
    public Result<Boolean> deleteScenicSpot(@RequestParam Integer id){
        return scenicSpotService.deleteScenicSpot(id);
    }

    /**
     * 根据id获取景区
     * @param id
     * @return
     */
    @GetMapping("/getScenicSpot")
    @Operation(summary = "根据id获取景区")
    public Result<ScenicSpotResponse> getScenicSpot(@RequestParam Integer id){
        return scenicSpotService.getScenicSpotById(id);
    }

    /**
     * 根据地区获取景区
     * @param address
     * @return
     */
    @GetMapping("/getScenicSpotByAddress")
    @Operation(summary = "根据地址获取景区")
    public Result<List<ScenicSpotResponse>> getScenicSpotByAddress(@RequestParam Integer address){
        return scenicSpotService.getScenicSpotByAddress(address);
    }

    /**
     * 获取景区列表
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "获取景区列表")
    public Result<List<ScenicSpotResponse>> listScenicSpot(){
        return scenicSpotService.listScenicSpot();
    }
}
